<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
	<ui:composition template="/templates/padraoJSF.xhtml">
		<ui:define name="barraTitulo">Cadastro de &Aacute;rea </ui:define>
			<ui:define name="conteudo">
				<p:tabView>
					<p:tab title="Manuten&ccedil;&atilde;o  ">
						<h:form  id="form">
							<p:dialog header="Mensagem" id="dialog1" widgetVar="dialog" fixedCenter="true" modal="true" visible="#{facesContext.maximumSeverity != null}">
					   			<p:messages/>                     
							</p:dialog>
							<h:panelGrid columns="2" columnClasses="width150 alinhaDir, width500" >	
								<h:outputText value="Descri&ccedil;&atilde;o:" styleClass="alinhaDir" />
								<h:inputText value="#{controleArea.descricaoPesquisa}" styleClass="textfield" size="100" />
								<h:outputText value="URL:" styleClass="alinhaDir" />
								<h:inputText value="#{controleArea.URLPesquisa}" styleClass="textfield" size="100" />
							</h:panelGrid>
							<h:panelGrid columns="2" columnClasses="width140 alinhaDir, width500">
								<h:outputLabel value=""/>
								<h:column headerClass="alinhaDir" >
									<h:commandLink action="#{controleArea.adicionar}" class="btnAcoes">
										<h:graphicImage url="/images/botoes/btnNovo.png" styleClass="hand" />
									</h:commandLink>
									<h:commandLink action="#{controleArea.limpar}" class="btnAcoes">
										<h:graphicImage url="/images/botoes/btnLimpar.png" styleClass="hand" />
										<f:ajax render=":form"/>
									</h:commandLink>								
									<h:commandLink action="#{controleArea.pesquisar}" class="btnAcoes">
										<h:graphicImage url="/images/botoes/btnPesquisar.png" styleClass="hand"  />
										<f:ajax render=":lista" execute="@form"/>
									</h:commandLink>				
									
								</h:column>
							</h:panelGrid>
						</h:form>
					</p:tab>
				</p:tabView>
				<h:form id="lista" >
					<p:dataTable value="#{controleArea.lista}" 
					             id="id_Lista"
					             var="area" 
					             paginator="true" 
					             rows="10" 
					             dynamic="true" 
					             rendered="#{not empty controleArea.lista}" 
								 firstPageLinkLabel="Primeiro"
					             previousPageLinkLabel="Anterior"
					             nextPageLinkLabel ="Pr&oacute;ximo"
					             lastPageLinkLabel="&Uacute;ltima"
					             emptyMessage="Nenhum resgistro encontrado"
					             errorMessage="Ocorreu um erro"	    			             
					             selectionMode="single">
						<p:column sortBy="#{area.codigoArea}" resizable="true" styleClass="width60" >
							<f:facet name="header">
								<h:outputText value="C&oacute;digo" />
							</f:facet>
							<h:outputText value="#{area.codigoArea}" />
						</p:column>
						<p:column sortBy="#{area.descricao}" resizable="true" >
							<f:facet name="header">
								<h:outputText value="Descri&ccedil;&atilde;o" />
							</f:facet>
							<h:outputText value="#{area.descricao}" />
						</p:column>
						<p:column sortBy="#{area.URL}" resizable="true" >
							<f:facet name="header">
								<h:outputText value="URL" />
							</f:facet>
							<h:outputText value="#{area.URL}" />
						</p:column>
						<p:column resizable="true" styleClass="width80">
							<f:facet name="header">
								<h:outputText value="A&ccedil;&atilde;o" /> 
							</f:facet>
							<h:commandLink action="#{controleArea.alterar}">  
								<h:graphicImage url="/images/marcadores/editar.png"  alt="Alterar &Aacute;rea"/>  
								<f:setPropertyActionListener target="#{controleArea.area}" value="#{area}" />
							</h:commandLink>
							<p:commandLink update="lista" oncomplete="dlg.show();">  
								<h:graphicImage url="/images/marcadores/excluir.png" alt="Excluir &Aacute;rea"/>  
								<f:setPropertyActionListener target="#{controleArea.area}" value="#{area}" />
							</p:commandLink>
                     	</p:column>
					</p:dataTable>
					<p:dialog header="Confirma&ccedil;&atilde;o" width="300" fixedCenter="true" widgetVar="dlg" visible="false">  
					<h:panelGrid columns="2" style="margin-bottom:10px">
						<h:column>   
							<h:outputLabel  value="Deseja Excluir?" />
						</h:column>
						<h:column >
							<p:commandButton value="Sim" action="#{controleArea.excluir}" update="id_Lista" oncomplete="dlg.hide();" />  
							<p:commandButton value="Nao" update="form" oncomplete="dlg.hide();"/>
						</h:column>  
					</h:panelGrid>  
				</p:dialog>
			</h:form>
		</ui:define>
	</ui:composition>
</html>